package main

import "fmt"

func projectionArea(grid [][]int) int {
	res := 0
	for i := 0; i < len(grid); i++ {
		for j := 0; j < len(grid[i]); j++ {
			if grid[i][j] > 0 {
				res++
			}
		}
	}
	for i := 0; i < len(grid); i++ {
		maxR := 0
		for j := 0; j < len(grid[i]); j++ {
			if grid[i][j] > maxR {
				maxR = grid[i][j]
			}
		}
		res += maxR
	}
	for j := 0; j < len(grid[0]); j++ {
		maxC := 0
		for i := 0; i < len(grid); i++ {
			if grid[i][j] > maxC {
				maxC = grid[i][j]
			}
		}
		res += maxC
	}
	return res
}

func main() {
	grid := [][]int{
		{1, 2},
		{3, 4},
	}
	res := projectionArea(grid)
	fmt.Println(res)
}
